package my.convert.attribute.processor.impl;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import java.util.Map;

import my.convert.attribute.processor.AttributeProcessor;


public class BasicTypeAttributeProcessor extends AttributeProcessor{

	@Override
	public Map<String, Class<?>> execute(Class<?> entityClazz, Map<String, Class<?>> mapper) {
		List<Field> fields = super.parseEntry(entityClazz);
		if(fields==null || fields.size()==0 || mapper==null)return null;
		for (Field field : fields) {
			Class<?> fieldClazz = field.getType(); // 得到field的class及类型全路径  
		    if(fieldClazz.isPrimitive() || fieldClazz.getName().startsWith("java.lang")
		    		||fieldClazz.isAssignableFrom(BigDecimal.class)||fieldClazz.isAssignableFrom(BigInteger.class)
		    		|| fieldClazz.isAssignableFrom(Date.class)) {    // //isPrimitive()判断是否为基本类型  
		    	mapper.put(field.getName(), fieldClazz);
		    }
		}
		return mapper;
	}
	
}
